#include "Scheduler.h"


Scheduler::Scheduler()
{
}


Scheduler::~Scheduler()
{

}

void Scheduler::AddEvent(GameObject* receiver, GameEvent* gameEvent)
{
	scheduledEvents.AddEvent(receiver, gameEvent);
}

void Scheduler::Simulate(World* world)
{
	bool finished = false;

	while(!finished)
	{
		// solve collision

		while(!scheduledEvents.Empty())
		{
			GameObject* object = scheduledEvents.ActivateFirst();

			world->Move(object, object->CellX(), object->CellY());

			scheduledEvents.DropFirst();
		}
		
		// emit empty

		finished = scheduledEvents.Empty();
	}

	
}
